<template>
  <div class="user">
    <div class="banner"></div>
    <div class="user_header">
      <div class="user_info">
        <img
          src="https://gw.alicdn.com/sns_logo/TB1ZbSH4AL0gK0jSZFtXXXQCXXa-240-240.png_120x120.jpg"
          alt=""
        />
        <div class="user_info_right">
          <div class="user_name">用户{{ account }}</div>
          <div class="user_id">{{ account }}</div>
        </div>
      </div>
      <div class="user_sign" @click="signIn">
        <span class="sign_btn">登录</span>
      </div>
    </div>

    <div class="tabs">
      <span
        @click="handleClick('Loading')"
        :class="{ active: load === 'Loading' }"
        >动态</span
      >
      <span
        @click="handleClick('Loading2')"
        :class="{ active: load === 'Loading2' }"
        >宝贝</span
      >
    </div>
    <keep-alive>
      <component :is="load"></component>
    </keep-alive>
  </div>
</template>

<script>
import { ref } from "vue";
import { useRouter } from "vue-router";
import Loading from "@/components/Loading/index.vue";
import Loading2 from "@/components/Loading2/index.vue";
import { useLocalStorage } from "@/hooks/useLocalStorage.js";
export default {
  components: {
    Loading,
    Loading2,
  },
  setup() {
    const load = ref("Loading");
    const account = useLocalStorage("account");
    const handleClick = (e) => {
      load.value = e;
    };

    // 登录,跳转到登录页面
    const router = useRouter();
    const signIn = () => {
      router.push("/login");
    };
    return {
      load,
      signIn,
      handleClick,
      account,
    };
  },
};
</script>

<style scoped>
.user {
  background: white;
}
.user_header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100px;
}
.banner {
  height: 200px;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  background-image: url("https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/0A/0C/ChMkJlwbaPmIfjr8AAHXNlQ9tyQAAt5PAMXql0AAddO522.jpg");
}
.user_info {
  position: relative;
  display: flex;
  width: 500px;
}
.user_info img {
  display: block;
  width: 100px;
  height: 100px;
  position: absolute;
  top: -50px;
  left: 4px;
}
.user_info_right {
  padding: 10px;
  margin-left: 120px;
  font-size: 20px;
  flex: 1;
}
.user_name {
  font-size: 40px;
  font-weight: 700;
}
.user_id {
  margin-top: 20px;
  color: #999;
  font-size: 3.2vw;
  line-height: 3.2vw;
}
.user_sign {
  height: 100%;
  width: 100px;
  text-align: center;
  margin-right: 20px;
  margin-top: 20px;
}
.sign_btn {
  display: inline-block;
  width: 80px;
  padding: 0 10px;
  font-weight: 500;
  border-radius: 20px;
  line-height: 100px;
  background: #f5f5f5;
  border: 1px #999 solid;
}
.tabs {
  margin-top: 40px;
  height: 80px;
  line-height: 80px;
  border-top: 1px solid rgb(182, 182, 182);
  border-bottom: 1px solid rgb(182, 182, 182);
  display: flex;
}
.tabs span {
  margin-left: 10px;
}
.active {
  color: #ff5000;
  font-weight: 700;
}
.showTable {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
  background: rgba(0, 0, 0, 0.5);
}
.main_show {
  width: 500px;
  height: 500px;
  font-size: 30px;
  color: white;
}
</style>